using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using SpaceHero.Screens;

namespace SpaceHero
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        ScreenManager screenManager;
        StateManager stateManager;
        GraphicsDeviceManager graphics; 

        SpriteBatch spriteBatch;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            screenManager = new ScreenManager(graphics); //Create a ScreenManager and initialize all screens
            stateManager = new StateManager(); //Create a StateManager and set starting states

            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            screenManager.LoadContent(stateManager.state, Content);
        }

        protected override void UnloadContent()
        {

        }

        protected override void Update(GameTime gameTime)
        {
            screenManager.Update(stateManager.state, gameTime, stateManager, Keyboard.GetState());

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            screenManager.Draw(stateManager.state, spriteBatch, graphics);

            base.Draw(gameTime);
        }
    }
}